//
//  ticketsCenter.m
//  RBIOSBase
//
//  Created by ren on 06/12/2017.
//  Copyright © 2017 bryan. All rights reserved.
//

#import "TicketsCenter.h"
#import "Seller.h"

@implementation TicketsCenter {
	NSLock *lock;
}

- (instancetype)init
{
	if (self = [super init]) {
		lock = [NSLock new];
	}
	return self;
}

- (void)sell:(Seller *)seller
{
	[lock lock];
	NSLog(@"seller.name----->%@", seller.name);
	if (self.tickets > 0) {
		NSLog(@"还剩余----->%d--->张火车票", self.tickets);
		[NSThread sleepForTimeInterval:2];
		self.tickets --;
	}
	else {
		NSLog(@"对不起，没有票了");
	}
	[lock unlock];
}

@end
